Add reranker result-mapping edge-case tests (#224) - #226
Merged
wpak-ai merged 1 commit intoJul 16, 2026
Conversation
Add tests for empty and absent rerank data (non-empty input still returns empty results, degraded=false), a data item with no document (maps to empty id/content instead of throwing), and duplicate documents (one result per data item). Each asserts the mapped SearchResult fields. Also extract a makePc helper to drop the repeated pc cast across the file. Closes cppalliance#224.
📝 WalkthroughWalkthroughThe rerank test suite adds a shared mock-construction helper and cases for empty or absent data, missing documents, and duplicate documents while preserving existing assertions. ChangesRerank mapping test coverage
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #226 +/- ##
=======================================
Coverage ? 85.61%
=======================================
Files ? 47
Lines ? 2488
Branches ? 857
=======================================
Hits ? 2130
Misses ? 357
Partials ? 1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
jonathanMLDev
approved these changes
Jul 16, 2026
2 tasks
wpak-ai
approved these changes
Jul 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the missing edge-case tests for
rerankResultsresult mapping (src/core/pinecone/rerank.ts). The suite previously covered only the happy path, empty input, and the rerank-throws fallback.New tests:
dataarray with a non-empty input returns empty reranked results withdegraded: falseand nodegradation_reason.data(response is{}) returns empty reranked results withdegraded: false.documentmaps to a result with emptyid/content/metadataandreranked: trueinstead of throwing.SearchResultper data item, with the fields preserved on each.Each test asserts the mapped
SearchResultfields (id, content, score, metadata, reranked). Also extracted a smallmakePchelper so the repeatedpccast lives in one place.This covers the live document-mapping path (
returnDocuments: true). The index-based remap cases (out-of-range index) are tracked in #227, gated on rerank moving toreturnDocuments: false, since there is no index-remap code to exercise today.Test-only change. rerank tests 7/7 pass,
format:checkand typecheck clean.Closes #224.
Summary by CodeRabbit